import { createDiscreteApi } from 'naive-ui'
import { naiveTheme } from '../theme/naive_theme'

const { message, dialog } = createDiscreteApi(
  [ 'message', 'dialog' ],
  { configProviderProps: { theme: naiveTheme as any } }
)

export function actOK(content: string) {
  message.success(content, {
    keepAliveOnHover: true,
    duration: 1000
  })
}

export function actErr(content: string) {
  message.error(content, {
    keepAliveOnHover: true,
    duration: 3000
  })
}

export function actLoaded() {
  message.success('', {
    duration: 1000
  })
}

export function actConfirm(
  content: string,
  title?: string,
  onPositiveClick?: () => void,
  onNegativeClick?: () => void
) {
  dialog.warning({
    title, content, onPositiveClick, onNegativeClick, positiveText: '确认', negativeText: '取消'
  })
}